package com.cn.team.controller;

import com.cn.common.pojo.ResultModel;
import com.cn.common.pojo.TeamModel;
import com.cn.team.service.TeamService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Api(tags = "人员信息")
@RestController
@RequestMapping("team")
public class TeamController {
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String date= DATE_FORMAT.format(new Date());
    @Autowired
    TeamService teamService;
    @GetMapping("teamForTeam")
    public ResultModel teamForTeam(){
        ResultModel teamForTeam = teamService.team();
        return teamForTeam;
    }
    @GetMapping("team")
    public ResultModel team(){
        ResultModel team = teamService.teamForHome();
        return team;
    }
    @GetMapping("delete")
    public ResultModel delete(int id){
        ResultModel delete = teamService.delete(id);
        return delete;
    }
    @PostMapping("update")
    public ResultModel update(TeamModel teamModel){
        ResultModel update = teamService.update(teamModel);
        return update;
    }
    @PostMapping(value = "insert")
    public ResultModel insert(TeamModel teamModel){
        ResultModel insert = teamService.insert(teamModel);
        return insert;
    }
    @PostMapping(value = "enable")
    public ResultModel enable(int id){
        ResultModel enable = teamService.enable(id);
        return enable;
    }
    @GetMapping("findById")
    public ResultModel findById(int id){
        ResultModel findById = teamService.findById(id);
        return findById;
    }
    @GetMapping("limit")
    public ResultModel limit(TeamModel teamModel,int limit,int page){
        teamModel.setPageNum(page);
        teamModel.setPageSize(limit);
        ResultModel resultModel = teamService.limit(teamModel);
        return resultModel;
    }
}
